home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / boekhoud / finan / BADGER finance v1.0 beta 2.exe / xampplite / phpMyAdmin / tbl_properties_structure.php < prev    next >
PHP Script  |  2006-02-13  |  34KB  |  815 lines

  1. <?php
  2. /* $Id: tbl_properties_structure.php,v 2.65.2.1 2006/02/14 10:23:44 cybot_tm Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5. require_once './libraries/common.lib.php';
  6. require_once './libraries/mysql_charsets.lib.php';
  7.  
  8. /**
  9.  * Drop multiple fields if required
  10.  */
  11.  
  12. // workaround for IE problem:
  13. if (isset($submit_mult_change_x)) {
  14.     $submit_mult = $strChange;
  15. } elseif (isset($submit_mult_drop_x)) {
  16.     $submit_mult = $strDrop;
  17. } elseif (isset($submit_mult_primary_x)) {
  18.     $submit_mult = $strPrimary;
  19. } elseif (isset($submit_mult_index_x)) {
  20.     $submit_mult = $strIndex;
  21. } elseif (isset($submit_mult_unique_x)) {
  22.     $submit_mult = $strUnique;
  23. } elseif (isset($submit_mult_fulltext_x)) {
  24.     $submit_mult = $strIdxFulltext;
  25. }
  26.  
  27. if ((!empty($submit_mult) && isset($selected_fld))
  28.     || isset($mult_btn)) {
  29.     $action = 'tbl_properties_structure.php';
  30.     $err_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db, $table);
  31.     require './libraries/mult_submits.inc.php';
  32. }
  33.  
  34. /**
  35.  * Runs common work
  36.  */
  37. require_once './libraries/tbl_properties_common.php';
  38. $url_query .= '&goto=tbl_properties_structure.php&back=tbl_properties_structure.php';
  39.  
  40. /**
  41.  * Prepares the table structure display
  42.  */
  43.  
  44. /**
  45.  * Gets tables informations
  46.  */
  47. require_once './libraries/tbl_properties_table_info.inc.php';
  48.  
  49. /**
  50.  * Show result of multi submit operation
  51.  */
  52. if ((!empty($submit_mult) && isset($selected_fld))
  53.     || isset($mult_btn)) {
  54.     $message = $strSuccess;
  55. }
  56.  
  57. /**
  58.  * Displays top menu links
  59.  */
  60. require_once './libraries/tbl_properties_links.inc.php';
  61.  
  62. // 2. Gets table keys and retains them
  63. $result      = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table) . ';');
  64. $primary     = '';
  65. $ret_keys    = array();
  66. $pk_array    = array(); // will be use to emphasis prim. keys in the table view
  67. while ($row = PMA_DBI_fetch_assoc($result)) {
  68.     $ret_keys[]  = $row;
  69.     // Backups the list of primary keys
  70.     if ($row['Key_name'] == 'PRIMARY') {
  71.         $primary .= $row['Column_name'] . ', ';
  72.         $pk_array[$row['Column_name']] = 1;
  73.     }
  74. } // end while
  75. PMA_DBI_free_result($result);
  76.  
  77. // 3. Get fields
  78. $fields_rs   = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
  79. $fields_cnt  = PMA_DBI_num_rows($fields_rs);
  80.  
  81. // Get more complete field information
  82. // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
  83. // but later, if the analyser returns more information, it
  84. // could be executed for any MySQL version and replace
  85. // the info given by SHOW FULL FIELDS FROM.
  86. //
  87. // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
  88. // SHOW FULL FIELDS says NULL and SHOW CREATE TABLE says NOT NULL (tested
  89. // in MySQL 4.0.25).
  90.  
  91. $show_create_table = PMA_DBI_fetch_value(
  92.         'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
  93.         0, 1);
  94. $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
  95.  
  96. /**
  97.  * prepare table infos
  98.  */
  99. // action titles (image or string)
  100. $titles = array();
  101. if ($cfg['PropertiesIconic'] == true) {
  102.     if ($cfg['PropertiesIconic'] === 'both') {
  103.         $iconic_spacer = '<div class="nowrap">';
  104.     } else {
  105.         $iconic_spacer = '';
  106.     }
  107.  
  108.     // images replaced 2004-05-08 by mkkeck
  109.     $titles['Change']        = $iconic_spacer
  110.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  111.         . 'b_edit.png" alt="' . $strChange . '" title="' . $strChange . '" />';
  112.     $titles['Drop']          = $iconic_spacer
  113.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  114.         . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
  115.     $titles['NoDrop']        = $iconic_spacer
  116.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  117.         . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
  118.     $titles['Primary']       = $iconic_spacer
  119.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  120.         . 'b_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
  121.     $titles['Index']         = $iconic_spacer
  122.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  123.         . 'b_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
  124.     $titles['Unique']        = $iconic_spacer
  125.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  126.         . 'b_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
  127.     $titles['IdxFulltext']   = $iconic_spacer
  128.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  129.         . 'b_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
  130.     $titles['NoPrimary']     = $iconic_spacer
  131.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  132.         . 'bd_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
  133.     $titles['NoIndex']       = $iconic_spacer
  134.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  135.         . 'bd_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
  136.     $titles['NoUnique']      = $iconic_spacer
  137.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  138.         . 'bd_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
  139.     $titles['NoIdxFulltext'] = $iconic_spacer
  140.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  141.         . 'bd_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
  142.     $titles['BrowseDistinctValues']        = $iconic_spacer
  143.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  144.         . 'b_browse.png" alt="' . $strBrowseDistinctValues . '" title="' . $strBrowseDistinctValues . '" />';
  145.  
  146.     if ($cfg['PropertiesIconic'] === 'both') {
  147.         $titles['Change']               .= $strChange . '</div>';
  148.         $titles['Drop']                 .= $strDrop . '</div>';
  149.         $titles['NoDrop']               .= $strDrop . '</div>';
  150.         $titles['Primary']              .= $strPrimary . '</div>';
  151.         $titles['Index']                .= $strIndex . '</div>';
  152.         $titles['Unique']               .= $strUnique . '</div>';
  153.         $titles['IdxFulltext'  ]        .= $strIdxFulltext . '</div>';
  154.         $titles['NoPrimary']            .= $strPrimary . '</div>';
  155.         $titles['NoIndex']              .= $strIndex . '</div>';
  156.         $titles['NoUnique']             .= $strUnique . '</div>';
  157.         $titles['NoIdxFulltext']        .= $strIdxFulltext . '</div>';
  158.         $titles['BrowseDistinctValues'] .= $strBrowseDistinctValues . '</div>';
  159.     }
  160. } else {
  161.     $titles['Change']               = $strChange;
  162.     $titles['Drop']                 = $strDrop;
  163.     $titles['NoDrop']               = $strDrop;
  164.     $titles['Primary']              = $strPrimary;
  165.     $titles['Index']                = $strIndex;
  166.     $titles['Unique']               = $strUnique;
  167.     $titles['IdxFulltext']          = $strIdxFulltext;
  168.     $titles['NoPrimary']            = $strPrimary;
  169.     $titles['NoIndex']              = $strIndex;
  170.     $titles['NoUnique']             = $strUnique;
  171.     $titles['NoIdxFulltext']        = $strIdxFulltext;
  172.     $titles['BrowseDistinctValues'] = $strBrowseDistinctValues;
  173. }
  174.  
  175. /**
  176.  * Displays the table structure ('show table' works correct since 3.23.03)
  177.  */
  178. /* TABLE INFORMATION */
  179. // table header
  180. $i = 0;
  181. ?>
  182. <form method="post" action="tbl_properties_structure.php" name="fieldsForm" id="fieldsForm">
  183.     <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  184. <table id="tablestructure" class="data">
  185. <thead>
  186. <tr>
  187.     <th id="th<?php echo ++$i; ?>"></th>
  188.     <th id="th<?php echo ++$i; ?>"><?php echo $strField; ?></th>
  189.     <th id="th<?php echo ++$i; ?>"><?php echo $strType; ?></th>
  190. <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? '    <th id="th' . ++$i . '">' . $strCollation . '</th>' . "\n" : ''; ?>
  191.     <th id="th<?php echo ++$i; ?>"><?php echo $strAttr; ?></th>
  192.     <th id="th<?php echo ++$i; ?>"><?php echo $strNull; ?></th>
  193.     <th id="th<?php echo ++$i; ?>"><?php echo $strDefault; ?></th>
  194.     <th id="th<?php echo ++$i; ?>"><?php echo $strExtra; ?></th>
  195. <?php if ($db_is_information_schema || $tbl_is_view) { ?>
  196.     <th id="th<?php echo ++$i; ?>"><?php echo $strView; ?></th>
  197. <?php } else { ?>
  198.     <th colspan="7" id="th<?php echo ++$i; ?>"><?php echo $strAction; ?></th>
  199. <?php } ?>
  200. </tr>
  201. </thead>
  202. <tbody>
  203. <?php
  204. unset($i);
  205.  
  206.  
  207. // table body
  208.  
  209. // prepare comments
  210. $comments_map = array();
  211. $mime_map = array();
  212.  
  213. if ($GLOBALS['cfg']['ShowPropertyComments']) {
  214.     require_once './libraries/relation.lib.php';
  215.     require_once './libraries/transformations.lib.php';
  216.  
  217.     $cfgRelation = PMA_getRelationsParam();
  218.  
  219.     if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
  220.         $comments_map = PMA_getComments($db, $table);
  221.  
  222.         if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
  223.             $mime_map = PMA_getMIME($db, $table, true);
  224.         }
  225.     }
  226. }
  227.  
  228. $rownum    = 0;
  229. $aryFields = array();
  230. $checked   = (!empty($checkall) ? ' checked="checked"' : '');
  231. $save_row  = array();
  232. $odd_row   = true;
  233. while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
  234.     $save_row[] = $row;
  235.     $rownum++;
  236.     $aryFields[]      = $row['Field'];
  237.  
  238.     $type             = $row['Type'];
  239.     // reformat mysql query output - staybyte - 9. June 2001
  240.     // loic1: set or enum types: slashes single quotes inside options
  241.     if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
  242.         $tmp[2]       = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
  243.         $type         = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
  244.  
  245.         // for the case ENUM('–','“')
  246.         $type         = htmlspecialchars($type);
  247.  
  248.         $type_nowrap  = '';
  249.  
  250.         $binary       = 0;
  251.         $unsigned     = 0;
  252.         $zerofill     = 0;
  253.     } else {
  254.         $type_nowrap  = ' nowrap="nowrap"';
  255.         // strip the "BINARY" attribute, except if we find "BINARY(" because
  256.         // this would be a BINARY or VARBINARY field type
  257.         if (!preg_match('@BINARY[\(]@i', $type)) {
  258.             $type         = preg_replace('@BINARY@i', '', $type);
  259.         }
  260.         $type         = preg_replace('@ZEROFILL@i', '', $type);
  261.         $type         = preg_replace('@UNSIGNED@i', '', $type);
  262.         if (empty($type)) {
  263.             $type     = ' ';
  264.         }
  265.  
  266.         if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
  267.             $binary           = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
  268.         } else {
  269.             $binary           = false;
  270.         }
  271.  
  272.         $unsigned     = stristr($row['Type'], 'unsigned');
  273.         $zerofill     = stristr($row['Type'], 'zerofill');
  274.     }
  275.  
  276.     // rabus: Divide charset from the rest of the type definition (MySQL >= 4.1)
  277.     unset($field_charset);
  278.     if (PMA_MYSQL_INT_VERSION >= 40100) {
  279.         if ((substr($type, 0, 4) == 'char'
  280.             || substr($type, 0, 7) == 'varchar'
  281.             || substr($type, 0, 4) == 'text'
  282.             || substr($type, 0, 8) == 'tinytext'
  283.             || substr($type, 0, 10) == 'mediumtext'
  284.             || substr($type, 0, 8) == 'longtext'
  285.             || substr($type, 0, 3) == 'set'
  286.             || substr($type, 0, 4) == 'enum'
  287.             ) && !$binary) {
  288.             if (strpos($type, ' character set ')) {
  289.                 $type = substr($type, 0, strpos($type, ' character set '));
  290.             }
  291.             if (!empty($row['Collation'])) {
  292.                 $field_charset = $row['Collation'];
  293.             } else {
  294.                 $field_charset = '';
  295.             }
  296.         } else {
  297.             $field_charset = '';
  298.         }
  299.     }
  300.  
  301.     // garvin: Display basic mimetype [MIME]
  302.     if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
  303.         $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
  304.     } else {
  305.         $type_mime = '';
  306.     }
  307.  
  308.     $attribute     = ' ';
  309.     if ($binary) {
  310.         $attribute = 'BINARY';
  311.     }
  312.     if ($unsigned) {
  313.         $attribute = 'UNSIGNED';
  314.     }
  315.     if ($zerofill) {
  316.         $attribute = 'UNSIGNED ZEROFILL';
  317.     }
  318.  
  319.     // MySQL 4.1.2+ TIMESTAMP options
  320.     // (if on_update_current_timestamp is set, then it's TRUE)
  321.     if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
  322.         $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
  323.     }
  324.  
  325.     // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
  326.     // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
  327.     // the latter.
  328.     if (!empty($analyzed_sql[0]['create_table_fields'][$row['Field']]['type']) && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null']) {
  329.         $row['Null'] = '';
  330.     }
  331.  
  332.  
  333.     if (!isset($row['Default'])) {
  334.         if ($row['Null'] == 'YES') {
  335.             $row['Default'] = '<i>NULL</i>';
  336.         }
  337.     } else {
  338.         $row['Default'] = htmlspecialchars($row['Default']);
  339.     }
  340.  
  341.     $field_encoded = urlencode($row['Field']);
  342.     $field_name    = htmlspecialchars($row['Field']);
  343.  
  344.     // garvin: underline commented fields and display a hover-title (CSS only)
  345.  
  346.     $comment_style = '';
  347.     if (isset($comments_map[$row['Field']])) {
  348.         $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
  349.     }
  350.  
  351.     if (isset($pk_array[$row['Field']])) {
  352.         $field_name = '<u>' . $field_name . '</u>';
  353.     }
  354.     echo "\n";
  355.     ?>
  356. <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
  357.     <td align="center">
  358.         <input type="checkbox" name="selected_fld[]" value="<?php echo $field_encoded; ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> />
  359.     </td>
  360.     <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $field_name; ?></label></th>
  361.     <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td>
  362. <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? '    <td>' . (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>') . '</td>' . "\n" : '' ?>
  363.     <td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></td>
  364.     <td><?php echo (($row['Null'] == 'YES') ? $strYes : $strNo); ?></td>
  365.     <td nowrap="nowrap"><?php if (isset($row['Default'])) { echo $row['Default']; } ?></td>
  366.     <td nowrap="nowrap"><?php echo $row['Extra']; ?></td>
  367.     <td align="center">
  368.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT COUNT(*) AS `' . $strRows . '`, `' . $row['Field'] . '` FROM `' . $table . '` GROUP BY `' . $row['Field'] . '` ORDER BY `' . $row['Field'] . '`'); ?>">
  369.             <?php echo $titles['BrowseDistinctValues']; ?></a>
  370.     </td>
  371.     <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
  372.     <td align="center">
  373.         <a href="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>">
  374.             <?php echo $titles['Change']; ?></a>
  375.     </td>
  376.     <td align="center">
  377.         <?php
  378.         // loic1: Drop field only if there is more than one field in the table
  379.         if ($fields_cnt > 1) {
  380.             echo "\n";
  381.             ?>
  382.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&cpurge=1&purgekey=<?php echo urlencode($row['Field']); ?>&zero_rows=<?php echo urlencode(sprintf($strFieldHasBeenDropped, htmlspecialchars($row['Field']))); ?>"
  383.             onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
  384.             <?php echo $titles['Drop']; ?></a>
  385.             <?php
  386.         } else {
  387.             echo "\n" . '        ' . $titles['NoDrop'];
  388.         }
  389.         echo "\n";
  390.         ?>
  391.     </td>
  392.     <td align="center">
  393.         <?php
  394.         if ($type == 'text' || $type == 'blob') {
  395.             echo $titles['NoPrimary'] . "\n";
  396.         } else {
  397.             echo "\n";
  398.             ?>
  399.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAPrimaryKey, htmlspecialchars($row['Field']))); ?>"
  400.             onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,'); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
  401.             <?php echo $titles['Primary']; ?></a>
  402.             <?php
  403.         }
  404.         echo "\n";
  405.         ?>
  406.     </td>
  407.     <td align="center">
  408.         <?php
  409.         if ($type == 'text' || $type == 'blob') {
  410.             echo $titles['NoUnique'] . "\n";
  411.         } else {
  412.             echo "\n";
  413.             ?>
  414.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
  415.             <?php echo $titles['Unique']; ?></a>
  416.             <?php
  417.         }
  418.         echo "\n";
  419.         ?>
  420.     </td>
  421.     <td align="center">
  422.         <?php
  423.         if ($type == 'text' || $type == 'blob') {
  424.             echo $titles['NoIndex'] . "\n";
  425.         } else {
  426.             echo "\n";
  427.             ?>
  428.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
  429.             <?php echo $titles['Index']; ?></a>
  430.             <?php
  431.         }
  432.         echo "\n";
  433.         ?>
  434.     </td>
  435.     <?php
  436.         if ((!empty($tbl_type) && $tbl_type == 'MYISAM')
  437.             && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'varchar'))) {
  438.             echo "\n";
  439.             ?>
  440.     <td align="center" nowrap="nowrap">
  441.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
  442.             <?php echo $titles['IdxFulltext']; ?></a>
  443.     </td>
  444.             <?php
  445.         } else {
  446.             echo "\n";
  447.         ?>
  448.     <td align="center" nowrap="nowrap">
  449.         <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
  450.     </td>
  451.         <?php
  452.         } // end if... else...
  453.         echo "\n";
  454.     } // end if (! $tbl_is_view && ! $db_is_information_schema)
  455.     ?>
  456. </tr>
  457.     <?php
  458.     unset($field_charset);
  459. } // end while
  460.  
  461. echo '</tbody>' . "\n"
  462.     .'</table>' . "\n";
  463.  
  464. $checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db, $table);
  465. ?>
  466.  
  467. <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
  468.     width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
  469. <a href="<?php echo $checkall_url; ?>&checkall=1"
  470.     onclick="if (markAllRows('fieldsForm')) return false;">
  471.     <?php echo $strCheckAll; ?></a>
  472. /
  473. <a href="<?php echo $checkall_url; ?>"
  474.     onclick="if (unMarkAllRows('fieldsForm')) return false;">
  475.     <?php echo $strUncheckAll; ?></a>
  476.  
  477. <i><?php echo $strWithChecked; ?></i>
  478.  
  479. <?php
  480. if ($cfg['PropertiesIconic']) {
  481.     PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', $strBrowse, 'b_browse.png');
  482. } else {
  483.     echo '<input type="submit" name="submit_mult" value="' . $strChange . '" title="' . $strChange . '" />' . "\n";
  484. }
  485. if (! $tbl_is_view && ! $db_is_information_schema) {
  486.     if ($cfg['PropertiesIconic']) {
  487.         PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $strChange, 'b_edit.png');
  488.         // Drop button if there is at least two fields
  489.         if ($fields_cnt > 1) {
  490.             PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', $strDrop, 'b_drop.png');
  491.         }
  492.         PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', $strPrimary, 'b_primary.png');
  493.         PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', $strUnique, 'b_unique.png');
  494.         PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', $strIndex, 'b_index.png');
  495.         if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) {
  496.             PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', $strIdxFulltext, 'b_ftext.png');
  497.         }
  498.     } else {
  499.         // Drop button if there is at least two fields
  500.         if ($fields_cnt > 1) {
  501.             echo '<i>' . $strOr . '</i>' . "\n"
  502.                . '<input type="submit" name="submit_mult" value="' . $strDrop . '" title="' . $strDrop . '" />' . "\n";
  503.         }
  504.         echo '<i>' . $strOr . '</i>' . "\n"
  505.            . '<input type="submit" name="submit_mult" value="' . $strPrimary . '" title="' . $strPrimary . '" />' . "\n";
  506.         echo '<i>' . $strOr . '</i>' . "\n"
  507.            . '<input type="submit" name="submit_mult" value="' . $strIndex . '" title="' . $strIndex . '" />' . "\n";
  508.         echo '<i>' . $strOr . '</i>' . "\n"
  509.            . '<input type="submit" name="submit_mult" value="' . $strUnique . '" title="' . $strUnique . '" />' . "\n";
  510.         if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) {
  511.             echo '<i>' . $strOr . '</i>' . "\n"
  512.                . '<input type="submit" name="submit_mult" value="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' . "\n";
  513.         }
  514.     }
  515. }
  516. ?>
  517. </form>
  518. <hr />
  519.  
  520. <?php
  521. /**
  522.  * Work on the table
  523.  */
  524. ?>
  525. <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
  526. if ($cfg['PropertiesIconic']) {
  527.     echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . $strPrintView . '"/>';
  528. }
  529. echo $strPrintView;
  530. ?></a>
  531.  
  532. <?php
  533.     if (! $tbl_is_view && ! $db_is_information_schema) {
  534.         // if internal relations are available, or the table type is INNODB
  535.     // ($tbl_type comes from libraries/tbl_properties_table_info.inc.php)
  536.  
  537.     if ($cfg['Server']['relation'] || $tbl_type=="INNODB") {
  538.         ?>
  539. <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
  540.         if ($cfg['PropertiesIconic']) {
  541.             echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . $strRelationView . '"/>';
  542.         }
  543.         echo $strRelationView;
  544.         ?></a>
  545.         <?php
  546.     }
  547.     ?>
  548. <a href="sql.php?<?php echo $url_query; ?>&session_max_rows=all&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()'); ?>"><?php
  549.     if ($cfg['PropertiesIconic']) {
  550.         echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />';
  551.     }
  552.     echo $strStructPropose;
  553.     ?></a><?php
  554.     echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
  555.     ?><br />
  556. <form method="post" action="tbl_addfield.php"
  557.     onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)">
  558.     <?php
  559.     echo PMA_generate_common_hidden_inputs($db, $table);
  560.     if ($cfg['PropertiesIconic']) {
  561.         echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . $strAddNewField . '"/>';
  562.     }
  563.     echo sprintf($strAddFields, '<input type="text" name="num_fields" size="2" maxlength="2" value="1" style="vertical-align: middle" onfocus="this.select()" />');
  564.     ?>
  565. <input type="radio" name="field_where" id="radio_field_where_last" value="last" checked="checked" /><label for="radio_field_where_last"><?php echo $strAtEndOfTable; ?></label>
  566. <input type="radio" name="field_where" id="radio_field_where_first" value="first" /><label for="radio_field_where_first"><?php echo $strAtBeginningOfTable; ?></label>
  567. <input type="radio" name="field_where" id="radio_field_where_after" value="after" /><?php
  568.     $fieldOptions = '</label><select name="after_field" style="vertical-align: middle" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
  569.     foreach ($aryFields as $fieldname) {
  570.         $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
  571.     }
  572.     unset($aryFields);
  573.     $fieldOptions .= '</select><label for="radio_field_where_after">';
  574.     echo str_replace('<label for="radio_field_where_after"></label>', '', '<label for="radio_field_where_after">' . sprintf($strAfter, $fieldOptions) . '</label>') . "\n";
  575.     ?>
  576. <input type="submit" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
  577. </form>
  578. <hr />
  579.     <?php
  580. }
  581.  
  582. /**
  583.  * If there are more than 20 rows, displays browse/select/insert/empty/drop
  584.  * links again
  585.  */
  586. if ($fields_cnt > 20) {
  587.     require './libraries/tbl_properties_links.inc.php';
  588. } // end if ($fields_cnt > 20)
  589. echo "\n\n";
  590.  
  591. /**
  592.  * Displays indexes
  593.  */
  594. echo '<div id="tablestatistics">' . "\n";
  595. if (! $tbl_is_view && ! $db_is_information_schema) {
  596.     define('PMA_IDX_INCLUDED', 1);
  597.     require './tbl_indexes.php';
  598. }
  599.  
  600. /**
  601.  * Displays Space usage and row statistics
  602.  */
  603. // BEGIN - Calc Table Space - staybyte - 9 June 2001
  604. // loic1, 22 feb. 2002: updated with patch from
  605. //                      Joshua Nye <josh at boxcarmedia.com> to get valid
  606. //                      statistics whatever is the table type
  607. if ($cfg['ShowStats']) {
  608.     $nonisam     = false;
  609.     $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
  610.     if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
  611.         $nonisam = true;
  612.     }
  613.  
  614.     // Gets some sizes
  615.     $mergetable     = false;
  616.     if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
  617.         $mergetable = true;
  618.     }
  619.     list($data_size, $data_unit)         = PMA_formatByteDown($showtable['Data_length']);
  620.     if ($mergetable == false) {
  621.         list($index_size, $index_unit)   = PMA_formatByteDown($showtable['Index_length']);
  622.     }
  623.     if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
  624.         list($free_size, $free_unit)     = PMA_formatByteDown($showtable['Data_free']);
  625.         list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']);
  626.     } else {
  627.         list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
  628.     }
  629.     list($tot_size, $tot_unit)           = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
  630.     if ($table_info_num_rows > 0) {
  631.         list($avg_size, $avg_unit)       = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
  632.     }
  633.  
  634.     // Displays them
  635.     $odd_row = false;
  636.     ?>
  637.  
  638.     <a name="showusage"></a>
  639.     <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
  640.     <table id="tablespaceusage" class="data">
  641.     <caption class="tblHeaders"><?php echo $strSpaceUsage; ?></caption>
  642.     <thead>
  643.     <tr>
  644.         <th><?php echo $strType; ?></th>
  645.         <th colspan="2"><?php echo $strUsage; ?></th>
  646.     </tr>
  647.     </thead>
  648.     <tbody>
  649.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  650.         <th class="name"><?php echo $strData; ?></th>
  651.         <td class="value"><?php echo $data_size; ?></td>
  652.         <td class="unit"><?php echo $data_unit; ?></td>
  653.     </tr>
  654.         <?php
  655.         if (isset($index_size)) {
  656.             ?>
  657.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  658.         <th class="name"><?php echo $strIndex; ?></th>
  659.         <td class="value"><?php echo $index_size; ?></td>
  660.         <td class="unit"><?php echo $index_unit; ?></td>
  661.     </tr>
  662.             <?php
  663.         }
  664.         if (isset($free_size)) {
  665.             ?>
  666.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
  667.         <th class="name"><?php echo $strOverhead; ?></th>
  668.         <td class="value"><?php echo $free_size; ?></td>
  669.         <td class="unit"><?php echo $free_unit; ?></td>
  670.     </tr>
  671.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  672.         <th class="name"><?php echo $strEffective; ?></th>
  673.         <td class="value"><?php echo $effect_size; ?></td>
  674.         <td class="unit"><?php echo $effect_unit; ?></td>
  675.     </tr>
  676.             <?php
  677.         }
  678.         if (isset($tot_size) && $mergetable == false) {
  679.             ?>
  680.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  681.         <th class="name"><?php echo $strTotalUC; ?></th>
  682.         <td class="value"><?php echo $tot_size; ?></td>
  683.         <td class="unit"><?php echo $tot_unit; ?></td>
  684.     </tr>
  685.             <?php
  686.         }
  687.         // Optimize link if overhead
  688.         if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'BDB')) {
  689.             ?>
  690.     <tr class="tblFooters">
  691.         <td colspan="3" align="center">
  692.             <a href="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
  693.             if ($cfg['PropertiesIconic']) {
  694.                echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . $strOptimizeTable. '" />';
  695.             }
  696.             echo $strOptimizeTable;
  697.             ?></a>
  698.         </td>
  699.     </tr>
  700.             <?php
  701.         }
  702.         ?>
  703.     </tbody>
  704.     </table>
  705.         <?php
  706.     }
  707.     $odd_row = false;
  708.     ?>
  709.     <table id="tablerowstats" class="data">
  710.     <caption class="tblHeaders"><?php echo $strRowsStatistic; ?></caption>
  711.     <thead>
  712.     <tr>
  713.         <th><?php echo $strStatement; ?></th>
  714.         <th><?php echo $strValue; ?></th>
  715.     </tr>
  716.     </thead>
  717.     <tbody>
  718.     <?php
  719.     if (isset($showtable['Row_format'])) {
  720.         ?>
  721.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  722.         <th class="name"><?php echo $strFormat; ?></th>
  723.         <td class="value"><?php
  724.         if ($showtable['Row_format'] == 'Fixed') {
  725.             echo $strFixed;
  726.         } elseif ($showtable['Row_format'] == 'Dynamic') {
  727.             echo $strDynamic;
  728.         } else {
  729.             echo $showtable['Row_format'];
  730.         }
  731.         ?></td>
  732.     </tr>
  733.         <?php
  734.     }
  735.     if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($tbl_collation)) {
  736.         ?>
  737.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  738.         <th class="name"><?php echo $strCollation; ?></th>
  739.         <td class="value"><?php
  740.             echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
  741.             ?></td>
  742.     </tr>
  743.         <?php
  744.     }
  745.     if (!$is_innodb && isset($showtable['Rows'])) {
  746.         ?>
  747.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  748.         <th class="name"><?php echo $strRows; ?></th>
  749.         <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
  750.     </tr>
  751.         <?php
  752.     }
  753.     if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
  754.         ?>
  755.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  756.         <th class="name"><?php echo $strRowLength; ?> ø</th>
  757.         <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
  758.     </tr>
  759.         <?php
  760.     }
  761.     if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
  762.         ?>
  763.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  764.         <th class="name"><?php echo $strRowSize; ?> ø</th>
  765.         <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
  766.     </tr>
  767.         <?php
  768.     }
  769.     if (isset($showtable['Auto_increment'])) {
  770.         ?>
  771.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  772.         <th class="name"><?php echo $strNext; ?> Autoindex</th>
  773.         <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
  774.     </tr>
  775.         <?php
  776.     }
  777.     if (isset($showtable['Create_time'])) {
  778.         ?>
  779.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  780.         <th class="name"><?php echo $strStatCreateTime; ?></th>
  781.         <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
  782.     </tr>
  783.         <?php
  784.     }
  785.     if (isset($showtable['Update_time'])) {
  786.         ?>
  787.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  788.         <th class="name"><?php echo $strStatUpdateTime; ?></th>
  789.         <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
  790.     </tr>
  791.         <?php
  792.     }
  793.     if (isset($showtable['Check_time'])) {
  794.         ?>
  795.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  796.         <th class="name"><?php echo $strStatCheckTime; ?></th>
  797.         <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
  798.     </tr>
  799.         <?php
  800.     }
  801.     ?>
  802.     </tbody>
  803.     </table>
  804.     <?php
  805. }
  806. // END - Calc Table Space
  807. echo '<div class="clearfloat"></div>' . "\n";
  808. echo '</div>' . "\n";
  809.  
  810. /**
  811.  * Displays the footer
  812.  */
  813. require_once './libraries/footer.inc.php';
  814. ?>
  815.